<?php
/**
 * Created by PhpStorm.
 * User: wg
 * Date: 16/4/20
 * Time: 11:00
 */
namespace C\mod{


    use C\lib\Db;

    class bag extends mod{

        protected static $__table_s = 'bag';
        protected static $__primary_s = 'id';

        // --- 抢包接口 ---

        public static function grab($id, $userId) {
            $pre = Db::prepare('UPDATE '.DB_PRE.'bag SET state = 1, user_id = :user_id WHERE id = :id AND state = 0');
            $pre->execute([
                ':user_id' => $userId,
                ':id' => $id
            ]);
            if($pre->rowCount() > 0)
                return true;
            else
                return false;
        }

    }

}

